<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../../vue.js"></script>
</head>

<body>
    <div id="app">
        <textarea v-model="myadd"></textarea>
        <div>
            <div>用户名：<input type="text" v-model="myadd" /></div>
            <input type="checkbox" v-model="isadd" />记住用户名
            <button @click="login">登录</button>
        </div>
        <hr />
        <div>
            <h2>注册页面</h2>
            <input type="checkbox" v-model="mymodel" value="Vue" /> Vue
            <input type="checkbox" v-model="mymodel" value="react" /> react
            <input type="checkbox" v-model="mymodel" value="nodejs" /> nodejs
            <hr /> {{mymodel}}
            <hr />
            <!-- 单选框 -->
            <div>
                <h2>性别</h2>
                <input type="radio" v-model="danx" value="n" />男
                <input type="radio" v-model="danx" value="v" />女
            </div>
        </div>
    </div>
    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                myadd: "",
                isadd: true,
                mymodel: [],
                danx: "n", //默认
            },
            methods: {
                login() {
                    if (this.isadd) {
                        localStorage.setItem("username", this.myadd);
                    }
                    console.log(this.myadd, this.mymodel, this.danx);
                },
            },
        });
    </script>
</body>

</html>